package com.chixing.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OrderFinishedConfig {
    //创建直连交换机
    @Bean("orderFinishedExchange")
    public DirectExchange newExchange(){
        return new DirectExchange("orderFinishedExchange",true,false);
    }
    //创建直连队列（修改订单状态）
    @Bean("orderFinishedQueue")
    public Queue payOrderQueue(){
        return new Queue("payOrderQueue",true);
    }
    //创建直连队列（修改商品库存）
    @Bean("decProductNumQueue")
    public Queue decProductNumQueue(){
        return new Queue("decProductNumQueue",true);
    }
    //创建直连队列（支付完消息推送）
//    @Bean("paySuccessMsgQueue")
//    public Queue paySuccessMsgQueue(){
//        return new Queue("paySuccessMsgQueue",true);
//    }
   //    创建直连队列修改优惠券的状态
    @Bean("newUpdateCouponQueue")
    public Queue newUpdateCouponQueue(){
        return new Queue("newUpdateCouponQueue",true,false,false);
    }
    //绑定
    @Bean
    public Binding binding1(){
        return BindingBuilder.bind(payOrderQueue()).to(newExchange()).with("PayOrder");
    }
    //绑定
    @Bean
    public Binding binding2(){
        return BindingBuilder.bind(decProductNumQueue()).to(newExchange()).with("DecProductNum");
    }
    //    绑定
    @Bean
    public Binding binding3(){
        return BindingBuilder.bind(newUpdateCouponQueue()).to(newExchange()).with("zhtUpdateKey");
    }
    //绑定
//    public Binding binding3(){
//        return BindingBuilder.bind(paySuccessMsgQueue()).to(newExchange()).with("OrderSuccessMsg");
//    }
}
